-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
countries- project by chen kaduri #22
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review my comments, they apply for your code in general.
I didn`t want to write the same thing again and again
@@ -29,7 +29,7 @@ | |||
</head> | |||
<body> | |||
<!-- Loader --> | |||
<div class="loader"> | |||
<div class="loader" id="loader"> | |||
<div class="spinner"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need both class and id ?
|
||
if (!countryName) { | ||
document.getElementById('country-name').innerHTML = '<p>No country selected!</p>'; | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use innerHTML
, it is a dangerous method
} | ||
|
||
fetch('CountriesData.json') | ||
.then(response => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded strings should be saved into constants file
|
||
//If the country is found, display its details | ||
if (country) { | ||
// Create the main container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid explaining the code with comments, is a bad practice.
The code should explain itself
|
||
// Create the flag section | ||
const flagContainer = document.createElement('div'); | ||
flagContainer.className = 'country-flag'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need to explain this with comment you can extract this into function named generateFlagSection
and just call it instead of the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment apply to everywhere in your code
const countryTitle = document.createElement('h1'); | ||
countryTitle.textContent = country.name; | ||
infoContainer.appendChild(countryTitle); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good instead of using innerHTML
countryRegion.appendChild(strongR); | ||
countryRegion.appendChild(document.createTextNode(country.region)); | ||
countryInfo.appendChild(countryRegion); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this page you have a lot of similar code again an again, can you think about a way to avoid it?
doing the project about countrie with use in css, js, html, json.
added filter function fetch the data from json.